package month4.day13;

import java.util.Scanner;

public class PCText {
    public static void main(String[] args) {
        System.out.println("新电脑采购成功请输入型号：");
        PC pc = new PC();
        Scanner in = new Scanner(System.in);
        pc.setBrand(in.next());
        System.out.println("请输入颜色：");
        pc.setColor(in.next());
        System.out.println("请输入分辨率：");
        pc.setSize(in.next());
        System.out.println("请输入硬盘容量：");
        pc.setHardDiskcapacity(in.nextInt());
        int fp=0;
        boolean qidon=false;
        boolean geshihua=false;
        boolean anzhuang=false;
        ck:
        while (true) {
            System.out.println("1:格式化，2：安装操作系统，3：启动，4：安装软件，5：下载软件，6：查看各盘情况，9：退出");
            int num = in.nextInt();
            if (num == 1&&qidon) {
                System.out.println("计划分为几个盘");
                fp = in.nextInt();
                System.out.println("请分别输入" + fp + "个盘符");
                String[]s1=new String[fp];
                for (int i = 0; i < fp; i++) {
                    s1[i]=in.next();
                }
                int sum = 0;
                int[]i1=new int[fp];
                for (int i = 0; i < fp; i++) {
                    System.out.println("请输入第" + (i + 1) + "个盘的大小");
                    i1[i] = in.nextInt();
                    sum = sum + i1[i];
                }
                if (sum <= pc.getHardDiskcapacity()) {
                    pc.fenpan(fp,s1,i1);
                    geshihua=true;
                    System.out.println("格式化成功");
                }else {
                System.out.println("硬盘容量不足，分配失败，请重新分配");
                }
            }else if (num == 2&&qidon&&geshihua) {
                while (true) {
                    System.out.println("请选择操作系统(1~3)，1:win7,2:win10,3(其他):win11");
                    int n = in.nextInt();
                    String os;
                    if (n == 1) {
                        os = "WIN7";
                    } else if (n == 2) {
                        os = "WIN10";
                    } else if (n == 3)
                        os = "WIN11";
                    break ;
                }
                while (true) {
                    System.out.println("请选择安装的盘：");
                    String azp = in.next();
                    if(pc.os(azp)!=null)
                        break ;
                }
            }else if (num == 3) {
                qidon=true;
                System.out.println("启动成功");
            }else if (num == 4) {
                System.out.println("1：普通软件，2：下载软件");
                int ruanjian = in.nextInt();
                System.out.println("软件名称：");
                String name = in.next();
                if(pc.chongming(fp,name)) {
                    System.out.println("软件重名");
                    continue;
                }
                System.out.println("软件大小：");
                double capacity = in.nextDouble();
                System.out.println("软件安装位置：");
                String dish = in.next();
                pc.software(ruanjian,name,capacity,dish);
            }else if (num == 5) {
                System.out.println("请选择一个下载软件：");
                for(int i=0;i<fp;i++){
                    for(int j=0;j<pc.dishes[i].soft;j++){
                        if(pc.dishes[i].softwares[j] instanceof Download){
                            System.out.println(pc.dishes[i].softwares[j].toString());
                        }
                    }
                }
                String name=in.next();
                int i=0;
                if(pc.software(name)==null) {
                    System.out.println("找不到该下载软件");
                    continue;
                }
                System.out.println("启动成功");
                System.out.println("下载软件名字：");
                String na = in.next();
                if(pc.chongming(fp,na)) {
                    System.out.println("软件重名");
                    continue;
                }
                System.out.println("软件大小：");
                double capacity = in.nextDouble();
                System.out.println("软件安装位置：");
                String dish = in.next();
                //这一步实际上没有下载文件，不知道怎么调用接口，想法是加一个文件类（暂时没有实现）
                pc.software(1,na,capacity,dish);
            } else if (num == 6) {
                System.out.println("请输入盘符：");
                String dish = in.next();
                pc.ruanjian(dish);
            }  else if (num == 9) {
                return;
            }

        }
    }
}
